/*
* Copyright (C) 2021 ~ 2022 Uniontech Technology Co., Ltd.
*
* Author:      zhangbingyi <zhangbingyi@uniontech.com>
*
* Maintainer:  zhangbingyi <zhangbingyi@uniontech.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "usbpolicykithelper.h"


#include <unistd.h>

USBPolicyKitHelper::USBPolicyKitHelper()
{
}

USBPolicyKitHelper::~USBPolicyKitHelper()
{
}

// 确认选择usb限制模式
void USBPolicyKitHelper::confirmSelectLimitationMode(int limitMode)
{
    // 权限验证
    bool ret = checkAuthorizationHelp();
    if (ret) {
        Q_EMIT notifyChangeLimitationMode(limitMode);
    }
}

// 确认添加到白名单
void USBPolicyKitHelper::confirmAddUsbConnectionWhiteLst(const USBConnectionInfo &info)
{
    // 权限验证
    bool ret = checkAuthorizationHelp();
    if (ret) {
        Q_EMIT notifyAddUsbConnectionWhiteLst(info);
    }
}

void USBPolicyKitHelper::authorizeChangeDevPerm(const USBConnectionInfo &info)
{
    // 权限验证
    bool ret = checkAuthorizationHelp();
    if (ret) {
        Q_EMIT notifyChangeDevPerm(info);
    }
}

// 确认是否清除usb连接记录
void USBPolicyKitHelper::confirmClearUsbConnectionLog()
{
    // 权限验证
    bool ret = checkAuthorizationHelp();
    if (ret) {
        Q_EMIT notifyClearUsbConnectionLog();
    }
}

// 确认导入白名单 -- 白名单页面
void USBPolicyKitHelper::confirmImportWhitelist()
{
    // 权限验证
    bool ret = checkAuthorizationHelp();
    if (ret) {
        Q_EMIT notifyShowImportWhitelistDlg();
    }
}
